package com.ruoyi.web.controller.tongban;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.tongban.domain.BusValueAddedServiceOrder;
import com.ruoyi.tongban.service.IBusValueAddedServiceOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 增值服务订单(视频,听书)Controller
 *
 * @author ruoyi
 * @date 2021-03-29
 */
@RestController
@RequestMapping("/tongban/order")
public class BusValueAddedServiceOrderController extends BaseController
{
    @Autowired
    private IBusValueAddedServiceOrderService busValueAddedServiceOrderService;

    /**
     * 查询增值服务订单(视频,听书)列表
     */
    @PreAuthorize("@ss.hasPermi('tongban:order:list')")
    @GetMapping("/list")
    public TableDataInfo list(BusValueAddedServiceOrder busValueAddedServiceOrder)
    {
        startPage();
        List<BusValueAddedServiceOrder> list = busValueAddedServiceOrderService.selectBusValueAddedServiceOrderList(busValueAddedServiceOrder);
        return getDataTable(list);
    }

    /**
     * 导出增值服务订单(视频,听书)列表
     */
    @PreAuthorize("@ss.hasPermi('tongban:order:export')")
    @Log(title = "增值服务订单(视频,听书)", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BusValueAddedServiceOrder busValueAddedServiceOrder)
    {
        List<BusValueAddedServiceOrder> list = busValueAddedServiceOrderService.selectBusValueAddedServiceOrderList(busValueAddedServiceOrder);
        ExcelUtil<BusValueAddedServiceOrder> util = new ExcelUtil<BusValueAddedServiceOrder>(BusValueAddedServiceOrder.class);
        return util.exportExcel(list, "order");
    }

    /**
     * 获取增值服务订单(视频,听书)详细信息
     */
    @PreAuthorize("@ss.hasPermi('tongban:order:query')")
    @GetMapping(value = "/{valueAddedServiceOrderId}")
    public AjaxResult getInfo(@PathVariable("valueAddedServiceOrderId") Long valueAddedServiceOrderId)
    {
        return AjaxResult.success(busValueAddedServiceOrderService.selectBusValueAddedServiceOrderById(valueAddedServiceOrderId));
    }

    /**
     * 新增增值服务订单(视频,听书)
     */
    @PreAuthorize("@ss.hasPermi('tongban:order:add')")
    @Log(title = "增值服务订单(视频,听书)", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BusValueAddedServiceOrder busValueAddedServiceOrder)
    {
        return toAjax(busValueAddedServiceOrderService.insertBusValueAddedServiceOrder(busValueAddedServiceOrder));
    }

    /**
     * 修改增值服务订单(视频,听书)
     */
    @PreAuthorize("@ss.hasPermi('tongban:order:edit')")
    @Log(title = "增值服务订单(视频,听书)", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BusValueAddedServiceOrder busValueAddedServiceOrder)
    {
        return toAjax(busValueAddedServiceOrderService.updateBusValueAddedServiceOrder(busValueAddedServiceOrder));
    }

    /**
     * 删除增值服务订单(视频,听书)
     */
    @PreAuthorize("@ss.hasPermi('tongban:order:remove')")
    @Log(title = "增值服务订单(视频,听书)", businessType = BusinessType.DELETE)
    @DeleteMapping("/{valueAddedServiceOrderIds}")
    public AjaxResult remove(@PathVariable Long[] valueAddedServiceOrderIds)
    {
        return toAjax(busValueAddedServiceOrderService.deleteBusValueAddedServiceOrderByIds(valueAddedServiceOrderIds));
    }
}
